﻿@model WorkTimePrj.Models.Item
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>新建工时记录</title>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.7.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/DatePicker/WdatePicker.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('#BtnSubmit').click(function () {
                if (valDate())
                    $('form').submit();
            });
            $('#account').change(function () {
                //debugger
                var acc = $(this).val();
                $.ajax({
                    type: "POST",
                    url: '@Url.Action("GetUserRole", "Item") ',
                    data: { account: acc },
                    cache: false,
                    success: function (ret) {
                        //debugger
                        var val = eval(ret)
                        $('#LI01').show();
                        $('#SP_role').text(val.msg);
                        $('#role').val(val.msg);
                    }
                });
            });           
        });
        function pickedFunc1() {
            var dayofwk = $dp.cal.getP('w');
            if (dayofwk != '01')
                alert('日期错误！只能选择星期一');
        }
        function valDate() {
            var date1 = new Date();
            date1.setFullYear($dp.$D('starttime').y, $dp.$D('starttime').M - 1, $dp.$D('starttime').d);
            var dayofwk1 = date1.getDay();
            if (dayofwk1 != 1) {
                alert('日期选择错误！');
                return false;
            }
            else {
                return true;
            }
        }
        var data =  @ViewBag.ProjectJson;
        $(document).ready(function () {            
            $("#pn").autocomplete({
                autoFocus: true,
                delay: 0,
                source: data,
                minLength: 0,
                select: function (event, ui) {
                     document.getElementById("pid").value = ui.item.ID; 

                     var pid = ui.item.ID;
                            $.ajax({
                                type: "POST",
                                url: '@Url.Action("GetStatus", "Item")',
                                data: { pid: pid },
                                cache: false,
                                success: function (ret) {
                                    //debugger
                                    var val = eval(ret)
                                    $('#LI02').show();
                                    $('#SP_status').text(val.msg);
                                    $('#status').val(val.msg);
                                }
                            });

                }
            }).click(function () {
                $(this).autocomplete("search", "");
            });
        });
    </script>
    <style type="text/css">
        .field-validation-error
        {
            float: none;
        }
        .body ul.cur li
        {
            /*height:30px; line-height:30px;*/
            padding: 10px;
            width: 100%;
            display: block;
            float: left;
        }
        .editor-label
        {
            width: 90px;
            float: left;
        }
        .editor-field
        {
            float: left;
        }
        .Button01
        {
            font-family: Verdana, Arial, Helvetica, sans-serif;
            font-size: 12px;
            color: #003677;
            height: 20px;
            border: solid 1px #5381B3;
            padding-left: 4px;
            padding-right: 4px;
            background: #ffffff;
        }
        .body ul.cur li.LI01
        {
            display: none;
        }
    </style>
</head>
<body>
    @using (Html.BeginForm())
    {
        <div class="form">
            <div class="sitemap">
                新建工时记录
            </div>
            <div class="body">
                <ul class="cur">
                    <li>
                        <div class="editor-label">
                            <label>
                                用户姓名</label>
                        </div>
                        <div class="editor-field">
                            @Html.DropDownListFor(model => model.account, (SelectList)ViewBag.uidSelectList, "---", new { @class = "Select" })
                            @{Html.ValidateFor(x => x.account);}
                            @Html.ValidationMessageFor(model => model.account)
                        </div>
                    </li>
                    <li class="LI01" id="LI01">
                        <div class="editor-label">
                            <label>
                                角色</label>
                        </div>
                        <div class="editor-field">
                            <span id="SP_role"></span>
                            @Html.HiddenFor(model => model.role)
                        </div>
                    </li>
                    <li>
                        <div class="editor-label">
                            <label>
                                所属项目</label>
                        </div>
                        <div class="editor-field">
                            <input type="text" class="input2" style="width: 400px" name="pn" id="pn" value="" />
                            <input type="text" class="input2" name="pid" id="pid" value="" style="display: none" />
                            @{Html.ValidateFor(x => x.pid);}
                            @Html.ValidationMessageFor(model => model.pid)
                        </div>
                    </li>
                    <li class="LI01" id="LI02" style="display: none">
                        <div class="editor-label">
                            <label>
                                项目状态</label>
                        </div>
                        <div class="editor-field">
                            <span id="SP_status"></span>
                            @Html.HiddenFor(model => model.status)
                        </div>
                    </li>
                    <li>
                        <div class="editor-label">
                            <label>
                                开始时间</label>
                        </div>
                        <div class="editor-field">
                            @Html.TextBoxFor(model => model.starttime, new { onclick = "WdatePicker({ dateFmt: 'yyyy-MM-dd', onpicked: pickedFunc1 })" })
                            @{Html.ValidateFor(x => x.starttime);}
                            @Html.ValidationMessageFor(model => model.starttime)
                        </div>
                    </li>
                    <li>
                        <div class="editor-label">
                            <label>
                                工作时长</label>
                        </div>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.cost)小时
                            @{Html.ValidateFor(x => x.cost);}
                            @Html.ValidationMessageFor(model => model.cost)
                        </div>
                    </li>
                    <li>
                        <div class="editor-label">
                            <label>
                                事项</label>
                        </div>
                        <div class="editor-field">
                            @Html.TextAreaFor(model => model.title, new { @style = "width:350px", rows = "5", cols = "70" })
                            @{Html.ValidateFor(x => x.title);}
                            @Html.ValidationMessageFor(model => model.title)
                        </div>
                    </li>
                    <li style="padding-left: 250px;">
                        <input id="BtnSubmit" type="button" value="保存" class="Button01" />
                    </li>
                </ul>
            </div>
        </div>
    }
    @Html.CommonnScript()
    <script type="text/javascript">
        if ('@ViewBag.refresh' == '1') {
            try {
                window.opener.location.reload();
            }
            catch (e)
            { }
            //window.close();
        }
         
    </script>
</body>
</html>
